<template>
    <baidu-map :center="center" :zoom="zoom" :max-zoom="17" @ready="handle" map-type="BMAP_HYBRID_MAP"
               :scroll-wheel-zoom="true" style="height: 100%">
        <el-card style="height: 9%" >
            <el-row align="right" :gutter="10" style="height: 100%">
                <el-col :span="8" style="min-height: 1px">
                </el-col>
                <el-col :span="2">
                    <el-button size="mini" @click="showAllMap">展示/收起全图</el-button>
                </el-col>
                <el-col :span="6">
                    <el-input v-model="positionMaker.name" size="mini" disabled></el-input>
                </el-col>
                <el-col :span="6">
                    <el-date-picker
                            v-model="dateValue"
                            type="date"
                            placeholder="选择日期"
                            size="mini">
                    </el-date-picker>
                </el-col>
                <el-col :span="2">
                    <el-button size="mini" @click="showPhoto">查看</el-button>
                </el-col>
            </el-row>
        </el-card>
        <bm-view style="width: 100%; height:90%; flex: 1"></bm-view>
        <bm-marker :position="positionMaker.soilPosition" :dragging="false"></bm-marker>
    </baidu-map>
</template>

<script>
    export default {
        name: "map-location",
        data() {
            return {
                center: {
                    lng: 114.9455555555,
                    lat: 41.422
                },
                dateValue: new Date(),
                zoom: 17,
                BMap: null,
                map: null,
                positionMaker: {
                    name: '地块一',
                    soilPosition: {
                        lng: 114.9455555555, lat: 41.422
                    }
                },
                allMap: false
            }
        },
        methods: {
            handle({BMap, map}) {
                this.map = map
            },
            showPhoto(){
                this.$parent.changeToPhoto()
            },
            showAllMap(){
                if(this.allMap){
                    document.getElementById('side_bar').style.width = 0 + '%'
                    this.allMap = !this.allMap
                } else {
                    document.getElementById('side_bar').style.width = 30 + '%'
                    this.allMap = !this.allMap


                }
            }
        }
    }
</script>

<style scoped>

</style>